package ooday03;
/**引用类型数组的演示 */
public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs = new Dog[2];
        dogs[0] = new Dog("小白",2,"黑");
        dogs[1] = new Dog("小黑",1,"白");
        for (int i = 0;i<= dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].LookHome();
        }


        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小黄",2,"黄");
        chicks[1] = new Chick("大黑",3,"黑");
        for (int i = 0;i<= chicks.length;i++){
            System.out.println(chicks[i].name);
            chicks[i].LayEggs();
        }

        Fish[] fish = new Fish[2];
        fish[0] = new Fish("小金",2,"金");
        fish[1] = new Fish("小红",5,"红");
        for (int i = 0;i<= fish.length;i++){
            System.out.println(fish[i].name);
            fish[i].swim();
        }



















        /*
        Dog [] dogs = new Dog[4];//声明Dog型数组dogs，包含四个元素，每个元素都是Dog型的，默认值为null
        dogs[0] = new Dog("小白",2,"黑");
        Chick [] chicks = new Chick[4];//声明Chick型数组chicks，包含四个元素，每个元素都是Chick型，默认值为null
        Fish [] fish = new Fish[5];//声明Fish型数组fish，包含五个元素，每个元素都是Fish型，默认值为null
        */




























    }
}
